<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>KylinV10 安装 MySQL 教程（可防踩雷） | ShuangChenYue</title>
    <meta name="generator" content="VuePress 1.9.9">
    <link rel="icon" href="https://cdn.jsdelivr.net/gh/cmty256/imgs-blog@main/logo/白云.38zbldnhh180.jpg">
    <meta name="description" content="满招损，谦受益">
    <meta name="keywords" content="专注于Cpp语言的旅行者">
    
    <link rel="preload" href="/assets/css/0.styles.3fffbd7d.css" as="style"><link rel="preload" href="/assets/js/app.c23950b3.js" as="script"><link rel="preload" href="/assets/js/2.4615a819.js" as="script"><link rel="preload" href="/assets/js/87.b0ad936b.js" as="script"><link rel="prefetch" href="/assets/js/10.5712a6b9.js"><link rel="prefetch" href="/assets/js/100.2b9c7044.js"><link rel="prefetch" href="/assets/js/101.b7031f7a.js"><link rel="prefetch" href="/assets/js/102.f5f3d542.js"><link rel="prefetch" href="/assets/js/11.64978825.js"><link rel="prefetch" href="/assets/js/12.4672093d.js"><link rel="prefetch" href="/assets/js/13.cda96393.js"><link rel="prefetch" href="/assets/js/14.0924c9b3.js"><link rel="prefetch" href="/assets/js/15.838c84fd.js"><link rel="prefetch" href="/assets/js/16.eb504b4c.js"><link rel="prefetch" href="/assets/js/17.10770306.js"><link rel="prefetch" href="/assets/js/18.47c8e9dc.js"><link rel="prefetch" href="/assets/js/19.9ccbab29.js"><link rel="prefetch" href="/assets/js/20.cfe64352.js"><link rel="prefetch" href="/assets/js/21.08ded76b.js"><link rel="prefetch" href="/assets/js/22.30a8a7ba.js"><link rel="prefetch" href="/assets/js/23.e55cce19.js"><link rel="prefetch" href="/assets/js/24.7def6d62.js"><link rel="prefetch" href="/assets/js/25.2b56efaf.js"><link rel="prefetch" href="/assets/js/26.3b3ea698.js"><link rel="prefetch" href="/assets/js/27.5c60f91f.js"><link rel="prefetch" href="/assets/js/28.2bbf1597.js"><link rel="prefetch" href="/assets/js/29.05fbd423.js"><link rel="prefetch" href="/assets/js/3.c7255874.js"><link rel="prefetch" href="/assets/js/30.54f725db.js"><link rel="prefetch" href="/assets/js/31.3e5c530d.js"><link rel="prefetch" href="/assets/js/32.f8ecda14.js"><link rel="prefetch" href="/assets/js/33.3bef3da7.js"><link rel="prefetch" href="/assets/js/34.0e1b1990.js"><link rel="prefetch" href="/assets/js/35.21acae61.js"><link rel="prefetch" href="/assets/js/36.744eb2f7.js"><link rel="prefetch" href="/assets/js/37.15a6e5e0.js"><link rel="prefetch" href="/assets/js/38.0fe5adf3.js"><link rel="prefetch" href="/assets/js/39.d873f04b.js"><link rel="prefetch" href="/assets/js/4.8844c7c6.js"><link rel="prefetch" href="/assets/js/40.a9c0394e.js"><link rel="prefetch" href="/assets/js/41.bd1b72f7.js"><link rel="prefetch" href="/assets/js/42.8c5ba50f.js"><link rel="prefetch" href="/assets/js/43.1c2fbec0.js"><link rel="prefetch" href="/assets/js/44.2601ff73.js"><link rel="prefetch" href="/assets/js/45.be6d6650.js"><link rel="prefetch" href="/assets/js/46.43c49e4e.js"><link rel="prefetch" href="/assets/js/47.915bfbea.js"><link rel="prefetch" href="/assets/js/48.2eab3613.js"><link rel="prefetch" href="/assets/js/49.80f28ebf.js"><link rel="prefetch" href="/assets/js/5.d85ca603.js"><link rel="prefetch" href="/assets/js/50.7807e666.js"><link rel="prefetch" href="/assets/js/51.1d274389.js"><link rel="prefetch" href="/assets/js/52.509cdcc1.js"><link rel="prefetch" href="/assets/js/53.aecfe03c.js"><link rel="prefetch" href="/assets/js/54.aa316fa4.js"><link rel="prefetch" href="/assets/js/55.b8aeead5.js"><link rel="prefetch" href="/assets/js/56.3e7b5654.js"><link rel="prefetch" href="/assets/js/57.3d08056f.js"><link rel="prefetch" href="/assets/js/58.00820ba6.js"><link rel="prefetch" href="/assets/js/59.4d4be159.js"><link rel="prefetch" href="/assets/js/6.b5c87a76.js"><link rel="prefetch" href="/assets/js/60.6089e8d9.js"><link rel="prefetch" href="/assets/js/61.2f20e8a2.js"><link rel="prefetch" href="/assets/js/62.03592460.js"><link rel="prefetch" href="/assets/js/63.77002dd4.js"><link rel="prefetch" href="/assets/js/64.9032ac20.js"><link rel="prefetch" href="/assets/js/65.1a70901c.js"><link rel="prefetch" href="/assets/js/66.f56322cc.js"><link rel="prefetch" href="/assets/js/67.b4720219.js"><link rel="prefetch" href="/assets/js/68.22b14d91.js"><link rel="prefetch" href="/assets/js/69.05d40a9b.js"><link rel="prefetch" href="/assets/js/7.b762b15a.js"><link rel="prefetch" href="/assets/js/70.58ee6b2e.js"><link rel="prefetch" href="/assets/js/71.c8c5e013.js"><link rel="prefetch" href="/assets/js/72.36050559.js"><link rel="prefetch" href="/assets/js/73.586878ae.js"><link rel="prefetch" href="/assets/js/74.249922dd.js"><link rel="prefetch" href="/assets/js/75.d2ec1b51.js"><link rel="prefetch" href="/assets/js/76.72fa47b7.js"><link rel="prefetch" href="/assets/js/77.63eb8e33.js"><link rel="prefetch" href="/assets/js/78.c551873e.js"><link rel="prefetch" href="/assets/js/79.dd1c3366.js"><link rel="prefetch" href="/assets/js/8.ce6b453e.js"><link rel="prefetch" href="/assets/js/80.3c1d3de0.js"><link rel="prefetch" href="/assets/js/81.0324d116.js"><link rel="prefetch" href="/assets/js/82.5d8ac119.js"><link rel="prefetch" href="/assets/js/83.6b6d94c4.js"><link rel="prefetch" href="/assets/js/84.142b2d74.js"><link rel="prefetch" href="/assets/js/85.63f77dcd.js"><link rel="prefetch" href="/assets/js/86.986eceed.js"><link rel="prefetch" href="/assets/js/88.e74f9927.js"><link rel="prefetch" href="/assets/js/89.d8a1d85d.js"><link rel="prefetch" href="/assets/js/9.cee9094a.js"><link rel="prefetch" href="/assets/js/90.ba242523.js"><link rel="prefetch" href="/assets/js/91.25593ea0.js"><link rel="prefetch" href="/assets/js/92.2bf12b05.js"><link rel="prefetch" href="/assets/js/93.90e9d9cd.js"><link rel="prefetch" href="/assets/js/94.9483ee0f.js"><link rel="prefetch" href="/assets/js/95.613a2f80.js"><link rel="prefetch" href="/assets/js/96.3a67111e.js"><link rel="prefetch" href="/assets/js/97.5b13c18d.js"><link rel="prefetch" href="/assets/js/98.7fb9a2ea.js"><link rel="prefetch" href="/assets/js/99.81da5e8b.js">
    <link rel="stylesheet" href="/assets/css/0.styles.3fffbd7d.css">
  </head>
  <body class="theme-mode-light">
    <div id="app" data-server-rendered="true"><div class="theme-container sidebar-open have-rightmenu"><header class="navbar blur"><div title="目录" class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/" class="home-link router-link-active"><img src="https://cdn.jsdelivr.net/gh/cmty256/imgs-blog@main/logo/白云.38zbldnhh180.jpg" alt="ShuangChenYue" class="logo"> <span class="site-name can-hide">ShuangChenYue</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/" class="nav-link">首页</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="CPP语言" class="dropdown-title"><!----> <span class="title" style="display:;">CPP语言</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/pages/c5bdd8/" class="nav-link">Cpp之旅</a></li><li class="dropdown-item"><!----> <a href="/pages/279e62/" class="nav-link">Cpp专栏</a></li><li class="dropdown-item"><!----> <a href="/pages/801755/" class="nav-link">Effective_CPP</a></li><li class="dropdown-item"><!----> <a href="/pages/6b2468/" class="nav-link">muduo网络库</a></li><li class="dropdown-item"><!----> <a href="/pages/5f8c9f/" class="nav-link">Unix环境高级编程</a></li><li class="dropdown-item"><!----> <a href="/pages/3f1d21/" class="nav-link">Cpp提高编程</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="计算机基础" class="dropdown-title"><!----> <span class="title" style="display:;">计算机基础</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/pages/7b1cb2/" class="nav-link">计算机网络</a></li><li class="dropdown-item"><!----> <a href="/pages/6048a8/" class="nav-link">操作系统</a></li><li class="dropdown-item"><!----> <a href="/pages/3b34ba/" class="nav-link">数据结构</a></li><li class="dropdown-item"><!----> <a href="/pages/412fe7/" class="nav-link">Linux</a></li><li class="dropdown-item"><!----> <a href="/pages/2dcfa1/" class="nav-link">算法</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="数据库" class="dropdown-title"><!----> <span class="title" style="display:;">数据库</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/pages/efa3f2/" class="nav-link">基础篇</a></li><li class="dropdown-item"><!----> <a href="/pages/ccc445/" class="nav-link">MySql</a></li><li class="dropdown-item"><!----> <a href="/pages/54616e/" class="nav-link">Redis</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="系统设计" class="dropdown-title"><!----> <span class="title" style="display:;">系统设计</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/pages/793d0a/" class="nav-link">权限校验</a></li><li class="dropdown-item"><!----> <a href="/pages/73ddd7/" class="nav-link">设计模式</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="开发日常" class="dropdown-title"><!----> <span class="title" style="display:;">开发日常</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/pages/71f6ae/" class="nav-link">Git知识总结</a></li><li class="dropdown-item"><!----> <a href="/pages/777b8a/" class="nav-link">nvm使用小结</a></li><li class="dropdown-item"><!----> <a href="/pages/ee770e/" class="nav-link">虚拟机固定 IP 地址</a></li><li class="dropdown-item"><!----> <a href="/pages/e472d1/" class="nav-link">随笔（持续更新）</a></li><li class="dropdown-item"><!----> <a href="/pages/411aa4/" class="nav-link">VScode 插件 CodeGeeX 使用教程</a></li><li class="dropdown-item"><!----> <a href="/pages/0d525d/" class="nav-link">KylinV10 将项目上传至 Github教程</a></li><li class="dropdown-item"><!----> <a href="/pages/ef40f0/" aria-current="page" class="nav-link router-link-exact-active router-link-active">KylinV10 安装 MySQL 教程（可防踩雷）</a></li><li class="dropdown-item"><!----> <a href="/pages/f8640c/" class="nav-link">个人博客代码推送教程</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="前端学习" class="dropdown-title"><!----> <span class="title" style="display:;">前端学习</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/pages/99897f/" class="nav-link">HTML与CSS</a></li><li class="dropdown-item"><!----> <a href="/pages/51542d/" class="nav-link">JS学习</a></li><li class="dropdown-item"><!----> <a href="/pages/803f9d/" class="nav-link">Vue3入门</a></li><li class="dropdown-item"><!----> <a href="/pages/ca4cfb/" class="nav-link">Vue3进阶</a></li><li class="dropdown-item"><!----> <a href="/pages/50e8d3/" class="nav-link">黑马Vue3</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="项目笔记" class="dropdown-title"><!----> <span class="title" style="display:;">项目笔记</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/pages/08dfe9/" class="nav-link">ip_file_hook</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="面经" class="dropdown-title"><!----> <span class="title" style="display:;">面经</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/pages/d69946/" class="nav-link">虎牙C++技术面经</a></li><li class="dropdown-item"><!----> <a href="/pages/29251d/" class="nav-link">金山一面复习</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="其它" class="dropdown-title"><!----> <span class="title" style="display:;">其它</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/pages/fa256e/" class="nav-link">博客搭建</a></li><li class="dropdown-item"><!----> <a href="/pages/335531/" class="nav-link">网站收藏箱</a></li></ul></div></div> <!----></nav></div></header> <div class="sidebar-mask"></div> <div class="sidebar-hover-trigger"></div> <aside class="sidebar" style="display:none;"><!----> <nav class="nav-links"><div class="nav-item"><a href="/" class="nav-link">首页</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="CPP语言" class="dropdown-title"><!----> <span class="title" style="display:;">CPP语言</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/pages/c5bdd8/" class="nav-link">Cpp之旅</a></li><li class="dropdown-item"><!----> <a href="/pages/279e62/" class="nav-link">Cpp专栏</a></li><li class="dropdown-item"><!----> <a href="/pages/801755/" class="nav-link">Effective_CPP</a></li><li class="dropdown-item"><!----> <a href="/pages/6b2468/" class="nav-link">muduo网络库</a></li><li class="dropdown-item"><!----> <a href="/pages/5f8c9f/" class="nav-link">Unix环境高级编程</a></li><li class="dropdown-item"><!----> <a href="/pages/3f1d21/" class="nav-link">Cpp提高编程</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="计算机基础" class="dropdown-title"><!----> <span class="title" style="display:;">计算机基础</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/pages/7b1cb2/" class="nav-link">计算机网络</a></li><li class="dropdown-item"><!----> <a href="/pages/6048a8/" class="nav-link">操作系统</a></li><li class="dropdown-item"><!----> <a href="/pages/3b34ba/" class="nav-link">数据结构</a></li><li class="dropdown-item"><!----> <a href="/pages/412fe7/" class="nav-link">Linux</a></li><li class="dropdown-item"><!----> <a href="/pages/2dcfa1/" class="nav-link">算法</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="数据库" class="dropdown-title"><!----> <span class="title" style="display:;">数据库</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/pages/efa3f2/" class="nav-link">基础篇</a></li><li class="dropdown-item"><!----> <a href="/pages/ccc445/" class="nav-link">MySql</a></li><li class="dropdown-item"><!----> <a href="/pages/54616e/" class="nav-link">Redis</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="系统设计" class="dropdown-title"><!----> <span class="title" style="display:;">系统设计</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/pages/793d0a/" class="nav-link">权限校验</a></li><li class="dropdown-item"><!----> <a href="/pages/73ddd7/" class="nav-link">设计模式</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="开发日常" class="dropdown-title"><!----> <span class="title" style="display:;">开发日常</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/pages/71f6ae/" class="nav-link">Git知识总结</a></li><li class="dropdown-item"><!----> <a href="/pages/777b8a/" class="nav-link">nvm使用小结</a></li><li class="dropdown-item"><!----> <a href="/pages/ee770e/" class="nav-link">虚拟机固定 IP 地址</a></li><li class="dropdown-item"><!----> <a href="/pages/e472d1/" class="nav-link">随笔（持续更新）</a></li><li class="dropdown-item"><!----> <a href="/pages/411aa4/" class="nav-link">VScode 插件 CodeGeeX 使用教程</a></li><li class="dropdown-item"><!----> <a href="/pages/0d525d/" class="nav-link">KylinV10 将项目上传至 Github教程</a></li><li class="dropdown-item"><!----> <a href="/pages/ef40f0/" aria-current="page" class="nav-link router-link-exact-active router-link-active">KylinV10 安装 MySQL 教程（可防踩雷）</a></li><li class="dropdown-item"><!----> <a href="/pages/f8640c/" class="nav-link">个人博客代码推送教程</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="前端学习" class="dropdown-title"><!----> <span class="title" style="display:;">前端学习</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/pages/99897f/" class="nav-link">HTML与CSS</a></li><li class="dropdown-item"><!----> <a href="/pages/51542d/" class="nav-link">JS学习</a></li><li class="dropdown-item"><!----> <a href="/pages/803f9d/" class="nav-link">Vue3入门</a></li><li class="dropdown-item"><!----> <a href="/pages/ca4cfb/" class="nav-link">Vue3进阶</a></li><li class="dropdown-item"><!----> <a href="/pages/50e8d3/" class="nav-link">黑马Vue3</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="项目笔记" class="dropdown-title"><!----> <span class="title" style="display:;">项目笔记</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/pages/08dfe9/" class="nav-link">ip_file_hook</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="面经" class="dropdown-title"><!----> <span class="title" style="display:;">面经</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/pages/d69946/" class="nav-link">虎牙C++技术面经</a></li><li class="dropdown-item"><!----> <a href="/pages/29251d/" class="nav-link">金山一面复习</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="其它" class="dropdown-title"><!----> <span class="title" style="display:;">其它</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/pages/fa256e/" class="nav-link">博客搭建</a></li><li class="dropdown-item"><!----> <a href="/pages/335531/" class="nav-link">网站收藏箱</a></li></ul></div></div> <!----></nav>  <ul class="sidebar-links"><li><a href="/pages/71f6ae/" class="sidebar-link">Git知识总结</a></li><li><a href="/pages/777b8a/" class="sidebar-link">nvm使用小结</a></li><li><a href="/pages/e472d1/" class="sidebar-link">随笔（持续更新）</a></li><li><a href="/pages/ee770e/" class="sidebar-link">虚拟机固定ip地址</a></li><li><a href="/pages/411aa4/" class="sidebar-link">VScode 插件 CodeGeex 使用教程</a></li><li><a href="/pages/0d525d/" class="sidebar-link">KylinV10 将项目上传至 Github</a></li><li><a href="/pages/ef40f0/" aria-current="page" class="active sidebar-link">KylinV10 安装 MySQL 教程（可防踩雷）</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header level2"><a href="/pages/ef40f0/#_1、直接用-apt-快捷安装-mysql" class="sidebar-link">1、直接用 apt 快捷安装 MySQL</a></li><li class="sidebar-sub-header level2"><a href="/pages/ef40f0/#_2、kylinv10-密码正确也无法登录的情况" class="sidebar-link">2、KylinV10 密码正确也无法登录的情况</a></li><li class="sidebar-sub-header level2"><a href="/pages/ef40f0/#_3、修改认证方式步骤" class="sidebar-link">3、修改认证方式步骤</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header level3"><a href="/pages/ef40f0/#_1、在-mysqld-cnf-最后一行里添加-skip-grant-tables" class="sidebar-link">1、在 mysqld.cnf 最后一行里添加 skip-grant-tables</a></li><li class="sidebar-sub-header level3"><a href="/pages/ef40f0/#_2、重启-mysql" class="sidebar-link">2、重启 MySQL</a></li><li class="sidebar-sub-header level3"><a href="/pages/ef40f0/#_3、连接-mysql" class="sidebar-link">3、连接 MySQL</a></li><li class="sidebar-sub-header level3"><a href="/pages/ef40f0/#_4、切换到-mysql-数据库" class="sidebar-link">4、切换到 mysql 数据库</a></li><li class="sidebar-sub-header level3"><a href="/pages/ef40f0/#_5、查看一下加密方式" class="sidebar-link">5、查看一下加密方式</a></li><li class="sidebar-sub-header level3"><a href="/pages/ef40f0/#_6、修改加密认证方式" class="sidebar-link">6、修改加密认证方式</a></li><li class="sidebar-sub-header level3"><a href="/pages/ef40f0/#_7、修改密码" class="sidebar-link">7、修改密码</a></li><li class="sidebar-sub-header level3"><a href="/pages/ef40f0/#_8、退出" class="sidebar-link">8、退出</a></li><li class="sidebar-sub-header level3"><a href="/pages/ef40f0/#_9、去掉-skip-grant-tables-重启-mysql-服务" class="sidebar-link">9、去掉 skip-grant-tables 重启 MySQL 服务</a></li><li class="sidebar-sub-header level3"><a href="/pages/ef40f0/#_10、重启-mysql-服务" class="sidebar-link">10、重启 MySQL 服务</a></li><li class="sidebar-sub-header level3"><a href="/pages/ef40f0/#_11、完整的过程图" class="sidebar-link">11、完整的过程图</a></li></ul></li><li class="sidebar-sub-header level2"><a href="/pages/ef40f0/#_4、还不行-还有招" class="sidebar-link">4、还不行？还有招</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header level3"><a href="/pages/ef40f0/#_1、初始化配置-设置密码" class="sidebar-link">1、初始化配置，设置密码</a></li><li class="sidebar-sub-header level3"><a href="/pages/ef40f0/#_2、检查mysql状态" class="sidebar-link">2、检查MySQL状态</a></li><li class="sidebar-sub-header level3"><a href="/pages/ef40f0/#_3、在终端连接" class="sidebar-link">3、在终端连接</a></li></ul></li><li class="sidebar-sub-header level2"><a href="/pages/ef40f0/#_5、sqoop-导入-mysql-中文乱码问题" class="sidebar-link">5、sqoop 导入 MySQL 中文乱码问题</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header level3"><a href="/pages/ef40f0/#_1-编辑配置文件。" class="sidebar-link">(1)编辑配置文件。</a></li><li class="sidebar-sub-header level3"><a href="/pages/ef40f0/#_2-在-mysqld-下添加一行" class="sidebar-link">(2)在[mysqld]下添加一行</a></li><li class="sidebar-sub-header level3"><a href="/pages/ef40f0/#_3-重启mysql服务。" class="sidebar-link">(3)重启MySQL服务。</a></li><li class="sidebar-sub-header level3"><a href="/pages/ef40f0/#_4-查看character-set-server设置" class="sidebar-link">(4)查看character_set_server设置</a></li></ul></li></ul></li><li><a href="/pages/f8640c/" class="sidebar-link">个人博客代码推送教程</a></li></ul> </aside> <div><main class="page"><div class="theme-vdoing-wrapper "><div class="articleInfo-wrap" data-v-06225672><div class="articleInfo" data-v-06225672><ul class="breadcrumbs" data-v-06225672><li data-v-06225672><a href="/" title="首页" class="iconfont icon-home router-link-active" data-v-06225672></a></li> <li data-v-06225672><span data-v-06225672>开发日常</span></li></ul> <div class="info" data-v-06225672><div title="作者" class="author iconfont icon-touxiang" data-v-06225672><a href="javascript:;" data-v-06225672>霜晨月</a></div> <div title="创建时间" class="date iconfont icon-riqi" data-v-06225672><a href="javascript:;" data-v-06225672>2023-12-21</a></div> <!----></div></div></div> <!----> <div class="content-wrapper"><div class="right-menu-wrapper"><div class="right-menu-margin"><div class="right-menu-title">目录</div> <div class="right-menu-content"></div></div></div> <h1><img src="">KylinV10 安装 MySQL 教程（可防踩雷）<!----></h1> <!----> <div class="theme-vdoing-content content__default"><h1 id="kylinv10-安装-mysql-教程-可防踩雷"><a href="#kylinv10-安装-mysql-教程-可防踩雷" class="header-anchor">#</a> KylinV10 安装 MySQL 教程（可防踩雷）</h1> <h2 id="_1、直接用-apt-快捷安装-mysql"><a href="#_1、直接用-apt-快捷安装-mysql" class="header-anchor">#</a> 1、直接用 apt 快捷安装 MySQL</h2> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code>$ <span class="token function">sudo</span> <span class="token function">apt-get</span> update <span class="token comment">#更新软件源</span>
$ <span class="token function">sudo</span> <span class="token function">apt-get</span> <span class="token function">install</span> mysql-server <span class="token comment">#安装mysql</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>然后你会发现，KylinV10 安装畅通无阻，并没有设置密码的场景，于是你一登陆，发现有密码（？哪来的密码）</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code>kylin@kylinV10:~/桌面$ mysql <span class="token parameter variable">-u</span> root <span class="token parameter variable">-p</span>
Enter password: 
ERROR <span class="token number">1698</span> <span class="token punctuation">(</span><span class="token number">28000</span><span class="token punctuation">)</span>: Access denied <span class="token keyword">for</span> user <span class="token string">'root'</span>@<span class="token string">'localhost'</span>
kylin@kylinV10:~/桌面$ mysql <span class="token parameter variable">-u</span> root <span class="token parameter variable">-p</span>
Enter password: 
ERROR <span class="token number">1698</span> <span class="token punctuation">(</span><span class="token number">28000</span><span class="token punctuation">)</span>: Access denied <span class="token keyword">for</span> user <span class="token string">'root'</span>@<span class="token string">'localhost'</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><h2 id="_2、kylinv10-密码正确也无法登录的情况"><a href="#_2、kylinv10-密码正确也无法登录的情况" class="header-anchor">#</a> 2、KylinV10 密码正确也无法登录的情况</h2> <p>这里有点问题的是，银河麒麟系统有点不同，按网上一些改密码的教程，会发现，密码该成功了，输入密码正确也无法登录，输入密码半天连接不了，也不知道是当时设置密码的时候打错了，两次都打错不应该啊。</p> <p><img src="https://cdn.jsdelivr.net/gh/xiaose-code/Pictures@main/img/1703062515988.webp" alt="1703062515988"></p> <p>其实这里主要原因就是因为 kylinV10 的加密方式不一样，MySQL 一般是 mysql_native_password 认证方式，但是 kylinV10 的认证方式是 auth_socket。所以要先改这个，接下来教大家如何改！</p> <p><img src="https://cdn.jsdelivr.net/gh/xiaose-code/Pictures@main/img/1703062674335.webp" alt="1703062674335"></p> <h2 id="_3、修改认证方式步骤"><a href="#_3、修改认证方式步骤" class="header-anchor">#</a> 3、修改认证方式步骤</h2> <p>具体操作如下：</p> <h3 id="_1、在-mysqld-cnf-最后一行里添加-skip-grant-tables"><a href="#_1、在-mysqld-cnf-最后一行里添加-skip-grant-tables" class="header-anchor">#</a> 1、在 mysqld.cnf 最后一行里添加 skip-grant-tables</h3> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token comment"># 使用 gedit 或者 vim 命令都可以（二选一即可）</span>
<span class="token function">sudo</span> gedit /etc/mysql/mysql.conf.d/mysqld.cnf
<span class="token comment"># 使用 vim 命令</span>
<span class="token function">sudo</span> <span class="token function">vim</span> /etc/mysql/mysql.conf.d/mysqld.cnf
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><p>直接在最后一行添加</p> <div class="language-json line-numbers-mode"><pre class="language-json"><code>skip-grant-tables
# 如下图
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p><img src="https://cdn.jsdelivr.net/gh/xiaose-code/Pictures@main/img/1703062962414.webp" alt="1703062962414"></p> <p>保存后，退出，不用去管报什么错误警告，比如下图这样的</p> <p><img src="C:%5CUsers%5Ctq%5CDesktop%5C4.png" alt="4"></p> <h3 id="_2、重启-mysql"><a href="#_2、重启-mysql" class="header-anchor">#</a> 2、重启 MySQL</h3> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">sudo</span> <span class="token function">service</span> mysql restart
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h3 id="_3、连接-mysql"><a href="#_3、连接-mysql" class="header-anchor">#</a> 3、连接 MySQL</h3> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token comment"># 只需要输入mysql就行，其他不用</span>
mysql
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><h3 id="_4、切换到-mysql-数据库"><a href="#_4、切换到-mysql-数据库" class="header-anchor">#</a> 4、切换到 mysql 数据库</h3> <div class="language-mysql line-numbers-mode"><pre class="language-text"><code>use mysql;
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h3 id="_5、查看一下加密方式"><a href="#_5、查看一下加密方式" class="header-anchor">#</a> 5、查看一下加密方式</h3> <div class="language-mysql line-numbers-mode"><pre class="language-text"><code>select user, plugin from user;
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><img src="https://cdn.jsdelivr.net/gh/xiaose-code/Pictures@main/img/1703062674335.webp" alt="1703062674335" style="zoom:67%;"> <p>如果是如图 auth_socket 需要将其修改为 mysql_native_password 这就是为什么我改了几次密码，都还是无法连接成功的原因：身份验证的插件是错的。</p> <h3 id="_6、修改加密认证方式"><a href="#_6、修改加密认证方式" class="header-anchor">#</a> 6、修改加密认证方式</h3> <div class="language-mysql line-numbers-mode"><pre class="language-text"><code>update user set plugin='mysql_native_password' where user='root';
flush privileges;
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><h3 id="_7、修改密码"><a href="#_7、修改密码" class="header-anchor">#</a> 7、修改密码</h3> <div class="language-mysql line-numbers-mode"><pre class="language-text"><code>ALTER user 'root'@'localhost' IDENTIFIED BY '123456'; //123456是新密码，改成你自己的
# 注意 MySQL8.0是不支持 password() 函数的，所以以下命令是无效的 
# 如果你安装的是MySQL5.x可以执行下面命令
update user set authentication_string=password(&quot;123456&quot;),plugin='mysql_native_password' where user='root';
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><h3 id="_8、退出"><a href="#_8、退出" class="header-anchor">#</a> 8、退出</h3> <div class="language-mysql line-numbers-mode"><pre class="language-text"><code>exit;
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h3 id="_9、去掉-skip-grant-tables-重启-mysql-服务"><a href="#_9、去掉-skip-grant-tables-重启-mysql-服务" class="header-anchor">#</a> 9、去掉 skip-grant-tables 重启 MySQL 服务</h3> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">sudo</span> gedit /etc/mysql/mysql.conf.d/mysqld.cnf
<span class="token comment"># 可以选择删除或者注释掉，注释的话在前面加个 # 就行了</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><h3 id="_10、重启-mysql-服务"><a href="#_10、重启-mysql-服务" class="header-anchor">#</a> 10、重启 MySQL 服务</h3> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">sudo</span> <span class="token function">service</span> mysql restart
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h3 id="_11、完整的过程图"><a href="#_11、完整的过程图" class="header-anchor">#</a> 11、完整的过程图</h3> <p><img src="https://cdn.jsdelivr.net/gh/xiaose-code/Pictures@main/img/1703063339930.webp" alt="1703063339930"></p> <h2 id="_4、还不行-还有招"><a href="#_4、还不行-还有招" class="header-anchor">#</a> 4、还不行？还有招</h2> <h3 id="_1、初始化配置-设置密码"><a href="#_1、初始化配置-设置密码" class="header-anchor">#</a> 1、初始化配置，设置密码</h3> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">sudo</span> mysql_secure_installation
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>然后下面步骤有点多，注意认真看</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token comment"># 1</span>
Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD PLUGIN can be used to <span class="token builtin class-name">test</span> passwords
and improve security. It checks the strength of password
and allows the <span class="token function">users</span> to <span class="token builtin class-name">set</span> only those passwords <span class="token function">which</span> are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?
<span class="token comment"># 这里我选择了 No</span>
Press y<span class="token operator">|</span>Y <span class="token keyword">for</span> Yes, any other key <span class="token keyword">for</span> No: No
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br></div></div><div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token comment"># 2</span>
Please <span class="token builtin class-name">set</span> the password <span class="token keyword">for</span> root here<span class="token punctuation">..</span>.

New password: <span class="token punctuation">(</span>输入密码<span class="token punctuation">)</span>

Re-enter new password: <span class="token punctuation">(</span>重复输入<span class="token punctuation">)</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token comment"># 3</span>
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created <span class="token keyword">for</span> them. This is intended only <span class="token keyword">for</span>
testing, and to <span class="token function">make</span> the installation go a bit smoother.
You should remove them before moving into a production
environment.
<span class="token comment"># 我选择了 No</span>
Remove anonymous users? <span class="token punctuation">(</span>Press y<span class="token operator">|</span>Y <span class="token keyword">for</span> Yes, any other key <span class="token keyword">for</span> No<span class="token punctuation">)</span> <span class="token builtin class-name">:</span> No 
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div><div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token comment"># 4</span>
Normally, root should only be allowed to connect from

<span class="token string">'localhost'</span><span class="token builtin class-name">.</span> This ensures that someone cannot guess at

the root password from the network<span class="token punctuation">..</span>.
<span class="token comment"># 我选择了 Yes</span>
Disallow root login remotely? <span class="token punctuation">(</span>Press y<span class="token operator">|</span>Y <span class="token keyword">for</span> Yes, any other key <span class="token keyword">for</span> No<span class="token punctuation">)</span> <span class="token builtin class-name">:</span> Yes
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div><div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token comment">#5</span>

By default, MySQL comes with a database named <span class="token string">'test'</span> that

anyone can access<span class="token punctuation">..</span>.
<span class="token comment"># 我选择了 No</span>
Remove <span class="token builtin class-name">test</span> database and access to it? <span class="token punctuation">(</span>Press y<span class="token operator">|</span>Y <span class="token keyword">for</span> Yes, any other key <span class="token keyword">for</span> No<span class="token punctuation">)</span> <span class="token builtin class-name">:</span> No
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token comment">#6</span>

Reloading the privilege tables will ensure that all changes

made so far will take effect immediately.
<span class="token comment"># 我选择了 Yes</span>
Reload privilege tables now? <span class="token punctuation">(</span>Press y<span class="token operator">|</span>Y <span class="token keyword">for</span> Yes, any other key <span class="token keyword">for</span> No<span class="token punctuation">)</span> <span class="token builtin class-name">:</span> Yes
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><h3 id="_2、检查mysql状态"><a href="#_2、检查mysql状态" class="header-anchor">#</a> 2、检查MySQL状态</h3> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code>systemctl status mysql.service
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h3 id="_3、在终端连接"><a href="#_3、在终端连接" class="header-anchor">#</a> 3、在终端连接</h3> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code>mysql <span class="token parameter variable">-u</span> root -p<span class="token punctuation">;</span>

<span class="token comment"># 输入密码</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><h2 id="_5、sqoop-导入-mysql-中文乱码问题"><a href="#_5、sqoop-导入-mysql-中文乱码问题" class="header-anchor">#</a> 5、sqoop 导入 MySQL 中文乱码问题</h2> <p>（可以插入中文，但不能用sqoop导入中文）导致导入时中文乱码的原因是character_set_server默认设置是latin1</p> <p>可以单个设置修改编码方式<code>set character_set_server=utf8;</code>但是重启会失效，建议按以下方式修改编码方式。</p> <h3 id="_1-编辑配置文件。"><a href="#_1-编辑配置文件。" class="header-anchor">#</a> (1)编辑配置文件。</h3> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">sudo</span> <span class="token function">vim</span> /etc/mysql/mysql.conf.d/mysqld.cnf
<span class="token comment"># 或者</span>
<span class="token function">sudo</span> gedit /etc/mysql/mysql.conf.d/mysqld.cnf
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><h3 id="_2-在-mysqld-下添加一行"><a href="#_2-在-mysqld-下添加一行" class="header-anchor">#</a> (2)在[mysqld]下添加一行</h3> <div class="language-json line-numbers-mode"><pre class="language-json"><code>character_set_server=utf8
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><img src="https://cdn.jsdelivr.net/gh/xiaose-code/Pictures@main/img/1703064529576.webp" alt="1703064529576" style="zoom:50%;"> <h3 id="_3-重启mysql服务。"><a href="#_3-重启mysql服务。" class="header-anchor">#</a> (3)重启MySQL服务。</h3> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">service</span> mysql restart
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h3 id="_4-查看character-set-server设置"><a href="#_4-查看character-set-server设置" class="header-anchor">#</a> (4)查看<code>character_set_server</code>设置</h3> <div class="language-mysql line-numbers-mode"><pre class="language-text"><code>show variables like &quot;char%&quot;;
# 如下图，可以看到 character_set_server 已经变成了 utf8 了
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p><img src="https://cdn.jsdelivr.net/gh/xiaose-code/Pictures@main/img/1703064626187.webp" alt="1703064626187"></p></div></div> <!----> <div class="page-edit"><!----> <!----> <!----></div> <div class="page-nav-wapper"><div class="page-nav-centre-wrap"><a href="/pages/0d525d/" class="page-nav-centre page-nav-centre-prev"><div class="tooltip">KylinV10 将项目上传至 Github</div></a> <a href="/pages/f8640c/" class="page-nav-centre page-nav-centre-next"><div class="tooltip">个人博客代码推送教程</div></a></div> <div class="page-nav"><p class="inner"><span class="prev">
        ←
        <a href="/pages/0d525d/" class="prev">KylinV10 将项目上传至 Github</a></span> <span class="next"><a href="/pages/f8640c/">个人博客代码推送教程</a>→
      </span></p></div></div></div> <!----></main></div> <div class="footer"><!----> 
  Theme by
  <a href="https://github.com/xugaoyi/vuepress-theme-vdoing" target="_blank" title="本站主题">Vdoing</a> 
    | Copyright © 2023-2023
    <span>霜晨月</span></div> <div class="buttons"><div title="返回顶部" class="button blur go-to-top iconfont icon-fanhuidingbu" style="display:none;"></div> <div title="去评论" class="button blur go-to-comment iconfont icon-pinglun" style="display:none;"></div> <div title="主题模式" class="button blur theme-mode-but iconfont icon-zhuti"><ul class="select-box" style="display:none;"><li class="iconfont icon-zidong">
          跟随系统
        </li><li class="iconfont icon-rijianmoshi">
          浅色模式
        </li><li class="iconfont icon-yejianmoshi">
          深色模式
        </li><li class="iconfont icon-yuedu">
          阅读模式
        </li></ul></div></div> <!----> <!----> <!----></div><div class="global-ui"><canvas id="vuepress-canvas-cursor"></canvas></div></div>
    <script src="/assets/js/app.c23950b3.js" defer></script><script src="/assets/js/2.4615a819.js" defer></script><script src="/assets/js/87.b0ad936b.js" defer></script>
  </body>
</html>
